/* This code is extracted from NewSyndrome kernel source code. It not really works 
but it's a good test to know if lib works or not */


#include <stdlib.h>
#include <openssl/err.h>
#include <openssl/ssl.h>


int main (void)
{
	int sd;
	BIO *sbio;
	SSL *ssl;
	SSL_METHOD *meth;
	SSL_CTX *ctx;
	
	sd = 6; /* fake socket() call */
	
	SSL_library_init ();
	SSL_load_error_strings ();

	meth = SSLv23_method ();
	ctx = SSL_CTX_new (meth);

	SSL_CTX_load_verify_locations (ctx, "", 0);
#if (OPENSSL_VERSION_NUMBER < 0x00905100L)
	SSL_CTX_set_verify_depth (ctx, 1);
#endif
	
	ssl = SSL_new (ctx);
	
	sbio = BIO_new_socket (sd, BIO_NOCLOSE);
	SSL_set_bio (ssl, sbio, sbio);
	
	if (SSL_connect (ssl) <= 0)
		return (-1);
	
	SSL_free (ssl);
	SSL_CTX_free (ctx);
	
	return (0);
}
